<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Refactoring_Table_Table_Div
 *
 * @author campa
 */
include_once 'Answer_Patterns.php';
include_once 'Mount_DOM_tree.php';

class Refactoring_Table_Table_Div extends Answer_Patterns {

   public function start($domDocument) {
      $result = "";
      $mount_tree = new Mount_DOM_tree();

      $search = $domDocument->getElementsByTagName('table');

      foreach ($search as $f) {
         $tables = $f->getElementsByTagName('table');
//         print_r($tables);
//         echo "<pre>".$tables->length."</pre>";
         if( $tables->length >= 1 ){
//            echo "<pre>". print_r($tables->item(0)->getElementsByTagName('tr')) ."</pre>";
            
            $result .= parent::elementAnswerPatterns("&LT;$f->nodeName&GT;", $f->getLineNo(), $answer, "remova uma delas dubstitiundo por div's", " dentro de uma <strong>&LT;table&GT;</strong>, possívelmente uma delas pode ser removida");
//            $result .= parent::tableAnswer($mount_tree->structHTML($f, 2, 0), $mount_tree->structHTML($f, 1, 0));
         }
         
      }

      if (!empty($result)) {
         $result = parent::titleAnswerPatterns("Substituição de tabelas dentro de tabelas") . $result;
      }

      return $result;
   }

}
